﻿using System;

namespace _32_到底调用了谁_继承与多态
{
    class Program
    {
        static void Main(string[] args)
        {
            Animal a1 = new Cat();
            Animal a2 = new Rabbit();
            Animal a3 = new Dob();

            //分别访问他们的属性
            Console.WriteLine($"这只宠物是{a1.Name}");
            Console.WriteLine($"这只宠物是{a2.Name}");
            Console.WriteLine($"这只宠物是{a3.Name}");
        }
    }

    abstract  class Animal
    {
        public abstract string Name { get; }
    }
    //声明三个类，都实现Animal抽象类，即从Animal类派生
    class Cat : Animal
    {
        public override string Name => "猫猫";
    }
    class Rabbit : Animal
    {
        public override string Name => "兔子";
    }
    class Dob : Animal
    {
        public override string Name => "狗狗";

    }
}
